package cn.ctodb.mall.goods.service.mapper;

import cn.ctodb.mall.goods.domain.*;
import cn.ctodb.mall.goods.service.dto.GoodAttrDTO;

import org.mapstruct.*;
import java.util.List;

/**
 * Mapper for the entity GoodAttr and its DTO GoodAttrDTO.
 */
@Mapper(componentModel = "spring", uses = {GoodsMapper.class, })
public interface GoodAttrMapper {

    @Mapping(source = "goods.id", target = "goodsId")
    GoodAttrDTO goodAttrToGoodAttrDTO(GoodAttr goodAttr);

    List<GoodAttrDTO> goodAttrsToGoodAttrDTOs(List<GoodAttr> goodAttrs);

    @Mapping(source = "goodsId", target = "goods")
    GoodAttr goodAttrDTOToGoodAttr(GoodAttrDTO goodAttrDTO);

    List<GoodAttr> goodAttrDTOsToGoodAttrs(List<GoodAttrDTO> goodAttrDTOs);
    /**
     * generating the fromId for all mappers if the databaseType is sql, as the class has relationship to it might need it, instead of
     * creating a new attribute to know if the entity has any relationship from some other entity
     *
     * @param id id of the entity
     * @return the entity instance
     */
     
    default GoodAttr goodAttrFromId(Long id) {
        if (id == null) {
            return null;
        }
        GoodAttr goodAttr = new GoodAttr();
        goodAttr.setId(id);
        return goodAttr;
    }
    

}
